<?php
/**
 * Created by PhpStorm.
 * securityr: VJLau
 * Date: 2018/1/30
 * Time: 下午3:12
 */

load()->func('tpl');

$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ($operation == 'display') {
    $pindex = max(1, intval($_GPC['page']));
    $psize = 20;
    $m_id = intval($_GPC['m_id']);
    $member_str = '';
    if (!empty($m_id)) $member_str = 'AND member_id = ' . $m_id;
    $list = pdo_fetchall("SELECT * FROM "
        . tablename('bontrip_single_order') . " WHERE uniacid = '{$uniacid}'{$member_str} and deleted_at is null and status = 1"
        . " ORDER BY id DESC LIMIT "
        . ($pindex - 1) * $psize . ',' . $psize);
    $total = pdo_fetchcolumn("SELECT COUNT(*) FROM "
        . tablename('bontrip_single_order') . "WHERE uniacid = '{$uniacid}'{$member_str} and deleted_at is null and status = 1");
    $pager = pagination($total, $pindex, $psize);
} elseif ($operation == 'detail') {
    $id = intval($_GPC['id']);
    $order = pdo_fetch("select * from " . tablename('bontrip_single_order') . " where id={$id} and uniacid={$uniacid}");
    $order['security_desc'] = unserialize($order['security_desc']);
    $order['notice_desc'] = unserialize($order['notice_desc']);
    $sku = unserialize($order['sku']);
    if ($order['adult_number'] > 0) {
        $order['adult_members'] = unserialize($order['adult_members']);
    }
    if ($order['child_number'] > 0) {
        $order['child_members'] = unserialize($order['child_members']);
    }

    if ($order['baby_number'] > 0) {
        $order['baby_members'] = unserialize($order['baby_members']);
    }

} else {
    message('请求方式不存在');

}
include $this->template('single_order', TEMPLATE_INCLUDEPATH, true);